package com.suge.home.module.screen.json;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.citrus.turbine.Context;
import com.alibaba.citrus.turbine.Navigator;
import com.suge.common.result.message.MessageResult;
import com.suge.message.dao.SmsMessageDAO;
import com.suge.message.dao.dataobject.SmsMessageDO;

public class QueryConfirmGoodsNotifySetting {


	@Autowired
    private HttpServletRequest request;
	@Autowired
	private SmsMessageDAO smsMessageDAO;
	public void setSmsMessageDAO(SmsMessageDAO smsMessageDAO) {
		this.smsMessageDAO = smsMessageDAO;
	}
	public void execute(Context context, Navigator nav) {
		
		String userIdStr = request.getParameter("userId");
	
		long serviceIdNumber =  4;
		MessageResult messageResult = smsMessageDAO.getSmsMessageTempletesByUserId(Long.parseLong(userIdStr));
		List<SmsMessageDO> messageList = messageResult.getSuccessList();
		boolean result  = false;
		SmsMessageDO smsRes  = null;
		if(messageList!=null && messageList.size()>0){
			for(SmsMessageDO sms: messageList){
				if(sms.getTypeId()==serviceIdNumber){
					result=true;
					   smsRes=sms;
					break;
				}
			}
		}
		context.put("isSuccess", result);
		context.put("sms", smsRes);

	}

	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}
	public HttpServletRequest getRequest() {
		return request;
	}



}
